<template>
	<!-- 问答列表 -->
	<div>
		<div class="list-wrapper flex-wrap">
			<div class="list-item" v-for="(item, index) in list" :key="index" @click="toPage(item)">
				<div class="top-box">
					<span class="title bold fs-16 fc-333 ellipsis2"> <i v-if="item.hot"
							class="icon iconfont icon-a-huo1"></i> {{item.title}}</span>
					<div class="content fs-14 fc-666 ellipsis2">
						{{getContent(item)}}
					</div>
				</div>
				<div class="img-box mt10" v-if="item.logoImgUrl">
					<van-image width="calc((100vw - 50px)/3)" height="calc((100vw - 50px)/3)"
						v-for="(imgItem, i) in item.logoImgHttpUrl.slice(0,3)" :key="i" fit="cover"
						:src="imgItem.fileContentUrl" />
				</div>
				<div class="bottom-box flex-wrap flex-text-mid space-between">
					<div class="left fs-12 fc-999">
						<span v-if="item.isRecommend === '1'" class="fc-primary mr10 nowrap">精华</span>
						<span>{{item.createByName}}</span>
						<span>{{item.pubDate}}</span>
					</div>
					<div v-if="item.applyStatus!=3&&item.applyStatus!=6&&postAudit" class="fs-12 fc-999 flex-wrap flex-text-mid flex-end auditResult">
            <span v-if="item.applyStatus ==2" class="nowrap danger">审核中</span>
            
            <span v-if="item.applyStatus ==0" class="nowrap danger reject">审核驳回：{{ item.auditReason }}</span>
          </div>
					<div v-else class="fs-12 fc-999 flex-wrap flex-text-mid flex-end">
						<span class="nowrap">{{item.viewNum}}查看</span>
						<span class="split-line"></span>
						<span class="nowrap">{{item.praiseNum}}点赞</span>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		getTime,
		getSurplusTime
	} from '@/assets/js/util'
	import {
		qywxLiveStatus,
		courseTypes
	} from '@/assets/js/constant'
	import vanImage from "@/components/vant/van-image/van-image.vue"
	export default {
		components:{vanImage},
		data() {
			return {}
		},
		props: {
			list: {
				type: Array,
				default: () => []
			},
			isMain: {
				type: Boolean,
				default: false
			},
			canUserEdit: { // 草稿
				type: Boolean,
				default: false
			},
			canAction: { // 草稿
				type: Boolean,
				default: false
			},
			postAudit:{
				type: Boolean,
				default: false
			}
		},
		computed: {
			...mapGetters({
				showTitle: 'siteInfo/showTitle'
			})
		},
		mounted() {},
		methods: {
			getStatus(val) {
				let ob = qywxLiveStatus.find(e => e.status == val)
				return ob ? ob.name : '未知'
			},
			getContent(info) {
				try {
					return decodeURIComponent(info.subContent)
				} catch (e) {
					return ''
				}
			},
			formatImg(logoImgUrl) {
				let arr = logoImgUrl && logoImgUrl.split(',')
				return arr
			},
			getTime(s) {
				return getTime(s)
			},
			getSurplusTime(s) {
				return getSurplusTime(s)
			},

			toPage(item) {
				if (this.canUserEdit) {
					this.$uniPush({
						name: 'forum-add',
						params: {
							id: item.forumId,
						},

					})
				} else {
					this.$uniPush({
						name: 'forum-detail-id',
						params: {
							id: item.forumId
						},
						query: {
							canAction: this.canAction ? 1 : 0
						}
					})
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.list-wrapper {
		flex-wrap: wrap;
		padding: 0 0 4px;
		background: #fff;
		.auditResult{
    overflow: hidden;
  }
		.reject{
    margin-top: 5px;
    width: 100%;
    overflow: hidden;
  }
		.list-item {
			width: 100%;
			border-bottom: 1px solid #EEEEEE;
			padding: 15px 0;

			&:last-child {
				border-bottom: none;
			}

			.top-box {
				text-align: justify;
				text-align-last: left;
				line-height: 22px;

				.title {
					.icon-a-huo1 {
						color: #f46267;
					}
				}

				.content {
					margin-top: 8px
				}
			}

			.bottom-box {
				margin-top: 8px;
				flex-wrap: wrap;

			}
		}

		.img-box {
			.van-image {
				&:not(:nth-child(3n)) {
					margin-right: 10px;
				}
			}
		}
	}
</style>